﻿import mx.utils.Delegate; 
import cn.eminia.A2.BE.utils;
class cn.eminia.A2.io.M1 {
	var ctrl:MovieClip;
	var scope, on1, onUp, state;
	function M1() { 
	}
	public static function to(scope:MovieClip, mc:MovieClip, vars:Object):Void { 
		var obj = {};
		obj.scope = scope;
		obj.on1 = (vars.on1!=null)?vars.on1:null;
		obj.on0 = (vars.on0!=null)?vars.on0:null;
		obj.onMouseDown = Delegate.create(obj, function () {
			if (mc.hitTest(_root._xmouse, _root._ymouse)) {
				//trace('click');
				Delegate.create(this.scope, this.on1)({it:mc, id:  utils.getLastID(mc._name)});
			}
			updateAfterEvent();
		});
		obj.onMouseUp =  function () {
			Delegate.create(this.scope, this.on0)( { it:mc, id:utils.getLastID(mc._name) } );
			updateAfterEvent();
		} 
		Mouse.addListener(obj);
		mc.__M1obj__ = obj ;
	} 
	public static function dispose(mc) { 
		
		Mouse.removeListener(mc.__M1obj__);
		delete mc.__M1obj__;
		mc.__M1obj__ = null;
		
	}
}
